package com.sell.service;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sell.entity.Orders;
import com.sell.mapper.OrdersMapper;

@Service("ordersService")
public class OrdersServiceImpl implements OrdersService {

	@Resource
	private OrdersMapper ordersMapper;

	// 添加订单
	public int addOrders(Orders orders) {
		List<Orders> ordersList = new ArrayList<Orders>();
		if(ordersList.equals(null)){
			return 0;
		}
		return ordersMapper.addOrders(orders);
	}

	// 查找订单
	public List<Orders> getAllOrder() throws Exception {
		List<Orders> ordersList = ordersMapper.getAllOrder();
		return ordersList;
	}

	// 删除订单
	public Orders deleteByOrders(String id) throws Exception {
		// 将页面上的String类型转换成Integer类型
		Integer ordersId = Integer.parseInt(id);
		// 将sevlet中传来的服务层转换成整型，再传到到层
		Orders order = ordersMapper.deleteByOrders(ordersId);
		//判断ID是否相等
		if (ordersId.equals(id)) {
			return order;
		}
		return null;
	}

}
